package com.cjst.service.impl.base;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cjst.dao.mapper.base.OrderIdDao;
import com.cjst.service.base.OrderIdService;

@Service
public class OrderIdServiceImpl implements OrderIdService {

	@Autowired
	private OrderIdDao orderIdDao;
	
	@Override
	public String getOrderIdByProc(String key) {
		Lock lock = new ReentrantLock();
		String orderNo = null;
		try {
			lock.lock();
			Map<String,String> map = new HashMap<>();
			map.put("seq", key);
			Map<String, String> orderMap =  orderIdDao.getOrderIdByProc(map);
			if(orderMap!=null) {
				orderNo = orderMap.get("a");
			}
		} catch (Exception e) {
			// TODO: handle exception
		}finally {
			lock.unlock();
		}
		return orderNo;
	}

}
